/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._2BinarySearch_PrefixSum
 * @File : Q0795.java
 * @Author : WangRuoyu
 * @Date 2023/3/13 22:35
 */

package acwing._2LanQiao._2BinarySearch_PrefixSum;

import java.util.Scanner;

/**
 * @Project : ProgrammingExercises
 * @Package : ACWing._2LanQiao._2BinarySearch_PrefixSum
 * @File : Q0795.java
 * @Author : WangRuoyu
 * @Date 2023/3/13 22:35
 */
public class Q0795 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int[] d = new int[n];

        for (int i = 0; i < d.length; i++) {
            d[i] = scan.nextInt();
        }

        int[] s = new int[n + 1];

        for (int i = 1; i < s.length; i++) {
            s[i] = d[i - 1] + s[i - 1];
        }

        for (int i = 0; i < m; i++) {
            int l = scan.nextInt();
            int r = scan.nextInt();
            System.out.println(s[r] - s[l - 1]);
        }
    }
}

//5 3
//2 1 3 6 4
//1 2
//1 3
//2 4
